#include <iostream>
#include "arm_neon.h"
#include <opencv2/opencv.hpp>

void vld1q_f32_test(float32_t *A, float32_t *B, float32_t *C){
    float32x4_t A0;
    float32x4_t B0;
    float32x4_t C0;
    
    A0 = vld1q_f32(A);
    B0 = vld1q_f32(B);
    
    C0 = vmovq_n_f32(0);
    
    // C0 = C0 + A0 * B0[0]
    C0 = vfmaq_laneq_f32(C0, A0, B0, 0);
    // C0 = C0 + A0 * B0[1]
    C0 = vfmaq_laneq_f32(C0, A0, B0, 1);
    C0 = vfmaq_laneq_f32(C0, A0, B0, 2);
    C0 = vfmaq_laneq_f32(C0, A0, B0, 3);
    vst1q_f32(C, C0);
}

int main(void){
    uint32_t n = 4;
    uint32_t m = 4;
    uint32_t k = 4;
//     cv::Mat A = cv::Mat::ones(n, k, CV_32FC1);
    cv::Mat A = (cv::Mat_<float32_t>(n,k) << 1,2,3,4, 5,6,7,8, 2,3,4,5, 6,7,8,9);
    cv::Mat B = cv::Mat::ones(k, m, CV_32FC1);
    cv::Mat C = cv::Mat::zeros(n, m, CV_32FC1);
    vld1q_f32_test((float32_t*)A.data, (float32_t*)B.data, (float32_t*)C.data);
    std::cout << A << std::endl;
    std::cout << B << std::endl;
    std::cout << C << std::endl;
    return 0;
}
